<%@ page import="ml.kgc.pojo.News" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: MaTengLong
  Date: 2021/4/5
  Time: 4:45

--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/common.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    //点击增加按钮后跳转到的页面，在该页面需要调用后台新闻增加功能
    //增加成功后，跳转到新闻列表页面，反之，跳转回新增页面
    request.setCharacterEncoding("utf-8");
    News news = new News();
    int categoryId = Integer.parseInt((request.getParameter("categoryId")));
    String title = request.getParameter("title");
    String author = request.getParameter("author");
    String summary = request.getParameter("summary");
    String newscontent = request.getParameter("newscontent");
    news.setCategoryId(categoryId);
    news.setTitle(title);
    news.setAuthor(author);
    news.setSummary(summary);
    news.setContent(newscontent);
    news.setCreateDate(new Date());

    boolean flag = newsService.addNews(news);
    if(flag){
        %>
    <jsp:forward page="newsDetailList.jsp"></jsp:forward>

    <%}else{%>
    <jsp:forward page="newsDetailCreateSimple.jsp"></jsp:forward>
    <%} %>


%>

</body>
</html>
